package com.dnjn.happiness.biz.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dnjn.happiness.biz.domain.EmotionType;
import com.dnjn.happiness.biz.mapper.EmotionTypeMapper;
import com.dnjn.happiness.biz.service.IEmotionTypeService;
import com.dnjn.happiness.common.core.constant.Constants;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 情绪类型 服务实现类
 * </p>
 *
 * @author Amber
 * @since 2023-10-09
 */
@Service
public class EmotionTypeServiceImpl extends ServiceImpl<EmotionTypeMapper, EmotionType> implements IEmotionTypeService {

    @Override
    public EmotionType getByCode(String code) {
        return lambdaQuery().eq(EmotionType::getCode, code).one();
    }

    @Override
    public void removeDomain(Long pkId) {
        lambdaUpdate().eq(EmotionType::getEtypeId, pkId).set(EmotionType::getDeleted, Constants.DELETED).update();
    }

    @Override
    public List<EmotionType> queryList(EmotionType domain) {
        return lambdaQuery(domain)
                .eq(EmotionType::getDeleted, Constants.UNDELETED)
                .list();
    }
}
